class Yhj {
    constructor(qr) {
        this.qr = qr.productid
        this.proList = document.querySelector('#proList')
        this.lis = this.proList.children
        console.log(this.proList.children);

        // console.log(this.qr);
        this.method()
        this.clk()
        //let { productid } = this.qr;//解构传递过来的productid这个参数
    }
    method() {
        fetch(`http://chst.vip:1234/api/getcouponproduct?couponid=${this.qr}`)
            .then(body => body.json())
            .then(res => {
                // console.log(res);
                this.render(res.result)
            })
    }
    render(data = []) {
        let newData = [...data]
        // console.log(newData);
        let page = ''
        newData.forEach(item => {
            page += `
            <li data-index="0">
                <a class="clearfix">
                    <div class="img fl">
                        ${item.couponProductImg}
                    </div>
                    <div class="infoR">
                        <h4>${item.couponProductName}</h4>
                        <p class="price">
                          ${item.couponProductPrice}
                        </p>
                       <p class="time">${item.couponProductTime}</p>
                    </div>
                </a>
            </li>
            `
        })
        this.proList.innerHTML = page
    }

    // 点击显示轮播图
    clk() {
        // console.log(this.proList.children);
        console.log(this.lis);
        for (let i = 0; i < this.lis.length; i++) {
            console.log(this);
            this.lis.addEventLitner('click', function () {
                console.log('1');
            })
        }
    }
}
// console.log(location.href);
let qr = getUrlParams(location.href)
// console.log(qr);
let yhj = new Yhj(qr)
